The present disclosure relates in general to web applications, and in particular to techniques for tracking the lifecycles of client-side browser windows in such applications.
Generally speaking, a web application is a software application that is hosted on a server and is accessible by users via a client-side web browser. In a typical use case, a user opens a client-side browser window and navigates to an initial web page of the application. From there, the user can input information (e.g., via form elements embedded in the page markup) and/or navigate to additional pages of the application to complete some task or transaction.
In some instances, the user may open a new browser window from the context of an existing browser window while accessing the application. This causes the browser to send a new request to the server for the application page displayed in the existing window. In current implementations, the server generally cannot distinguish between this new window event and a situation where the user has reloaded/refreshed the existing window—in either case, the request received by the server appears to originate from the existing window. This can be problematic since the server typically maintains separate application state information for each browser window, and accordingly needs to know which window it is serving before rendering a page. For example, if the server erroneously determines that a client request corresponds to a reload of an existing window (when it actually corresponds to the opening of a new window), the server may unintentionally modify the application state of the existing window when processing the request.
In other instances, the user may close a browser window that he/she has used for accessing the application, or navigate away from the application (e.g., to a third party web site) within the window. In current implementations, the server generally cannot distinguish between these situations and a situation where the user has navigated (within the window) to another web page in the same application—in either case, the server simply receives a notification from the browser that the application page in the window has been unloaded/destroyed. This can make it difficult for the server to determine when to free memory resources (e.g., application state information) that are maintained by the server for each browser window. For example, if the server erroneously determines that a browser window is still being used to access the application (when the user has actually closed the window or navigated away from the application), the server may keep the resources for the window in memory longer than necessary, which is undesirable from both an efficiency and security standpoint.